package com.marchsoft.controller;

import com.marchsoft.common.advice.CommonExceptionHandler;
import com.marchsoft.service.ITeacherService;
import com.marchsoft.vo.TeaOwnInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RestController;

/**
 * class description：
 * author：rsw
 * Date: 2019/11/17
 * Time: 9:15
 **/
@RestController
@RequestMapping("teacher")
public class TeacherController extends CommonExceptionHandler {

    @Autowired
    private ITeacherService teacherService;

    /**
     * 简单查询老师
     * @return
     */
    @RequestMapping("/queryAll")
    public ResponseEntity<List<Map>> queryGroupAll(
            @RequestParam(name = "sid",required = true) Integer sid
    ){
        return ResponseEntity.ok(teacherService.queryGroupAll(sid));
    }

    /**
     * 简单查询老师
     * @return
     */
    @RequestMapping(value = "/queryInfo")
    public ResponseEntity<Map<String,Object>> queryInfo(
            @RequestParam(name = "tid",required = true) Integer tid,
            @RequestParam(name = "sid",required = true) Integer sid
    ){
        return ResponseEntity.ok(teacherService.queryTeacherInfoById(tid,sid));
    }

    /**
     * 查询我的导师的团队
     * @param tid 导师id
     * @return
     */
    @RequestMapping(value = "/MyTeacher",method = RequestMethod.POST)
    public ResponseEntity<List<Object>> queryTeacherTeam(
            @RequestParam(name = "tid",required = true) Integer tid
    ){
        return ResponseEntity.ok(teacherService.queryTeacherTeam(tid));
    }

    /**
     * 提交导师申请
     * @param tid 导师id
     * @param sid 学生id
     * @return
     */
    @RequestMapping(value = "/submitApplications",method = RequestMethod.POST)
    public ResponseEntity<Integer> submitApplications(
            @RequestParam(name = "tid",required = true) Integer tid,
            @RequestParam(name = "sid",required = true) Integer sid
    ){
        teacherService.submitApplications(sid,tid);
        Integer status = 2;
        return ResponseEntity.ok(status);
    }

    /**
     * 导师端查询个人信息
     * @param tid
     * @return
     */
    @RequestMapping(value = "/ownInfo")
    public ResponseEntity<TeaOwnInfo> queryOwnInfo(
            @RequestParam(name = "tid") Integer tid
    ){
        return ResponseEntity.ok(teacherService.queryOwnInfo(tid));
    }



}

